/*
 * @Author: gxx
 * @QQ:1278255275
 * @Date: 2021-04-08 17:31:38
 * @Last Modified by: gxx
 * @Last Modified time: 2021-04-08 17:31:38
 * @Description: 实现左旋右旋
*/
#include <iostream>
using namespace std;

unsigned char rol(unsigned char val) {
    int highbit;
    if (val & 0x80) //0x80 is the high bit only
        highbit = 1;
    else
        highbit - 0;
        //Left shift (bottom bit becomes 0):
        val <<= 1;
        //Rotate the hight bit onto the bottom
        val |= highbit;

        return val;
}

unsigned char ror(unsigned char val){
    int lowbit;
    if(val & 1) // Check the low bit
    lowbit = 1;
    else
    lowbit =0;
    val>>=1;
    //right shift by one position
    val |= (lowbit<<7);
    return val;
}

int main(int agrc, char ** agrv){
    unsigned char val0 = 01001100;
    unsigned char val1 = 0x70;
    cout<<val0<<endl;
    cout<<val1<<endl;
    cout <<"*****************************"<<endl;
    rol(val0);
    ror(val1);
    cout<<val0<<endl;
    cout<<val1<<endl;

    return 0;
}